import { http } from "@/utils/http";
/**
 * CommentQueryRequest
 */
export interface CommentQueryRequest {
  articleId: number | null;
  onlyVisible: boolean | null;
  isNeedAudit: boolean | null;
}

/**
 * CommentListItemResultPageData
 */
export interface CommentListItemResultPageData {
  rows: Array<CommentListItemResult>;
  total: number;
}

/**
 * CommentListItemResult
 */
export interface CommentListItemResult {
  id: number;
  parentId: number;
  articleId: number;
  userId: number;
  userName: string;
  content: string;
  visible: boolean;
  /** 是否需要审核 */ isNeedAudit: boolean;
  /** 原因&lt;br&gt;如果验证不通过的话，可能会附上原因 */ reason: string;
  createTime: string;
  updateTime: string;
}

export class CommentApi {
  /**
   * 无
   */
  public list(
    query: {
      sort?: number;
      sortField?: string;
      page?: number;
      limit?: number;
    },
    param1?: CommentQueryRequest
  ): Promise<CommentListItemResultPageData> {
    return http.request({
      url: "/api/comment/list",
      method: "post",
      data: param1,
      params: {
        Sort: query.sort,
        SortField: query.sortField,
        Page: query.page,
        Limit: query.limit
      }
    });
  }
}
export default new CommentApi();
